; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes --check-globals
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC

define void @_ZN6openmc13FilterBinIterC1ERKNS_5TallyERNS_8ParticleE(i1 %c1, i1 %c2) {
; CHECK: Function Attrs: nofree norecurse nosync nounwind
; CHECK-LABEL: define {{[^@]+}}@_ZN6openmc13FilterBinIterC1ERKNS_5TallyERNS_8ParticleE
; CHECK-SAME: (i1 noundef [[C1:%.*]], i1 [[C2:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[D_I_I_I_I:%.*]] = alloca [3 x double], align 8
; CHECK-NEXT:    br i1 [[C1]], label [[FOR_BODY_LR_PH_I:%.*]], label [[_ZN6OPENMC13FILTERBINITERC2ERKNS_5TALLYERNS_8PARTICLEE_INTERNALIZED_EXIT:%.*]]
; CHECK:       for.body.lr.ph.i:
; CHECK-NEXT:    [[PHI_CAST_I_I_I_I:%.*]] = ptrtoint ptr [[D_I_I_I_I]] to i64
; CHECK-NEXT:    br label [[FOR_BODY_I:%.*]]
; CHECK:       for.body.i:
; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr inttoptr (i64 4 to ptr), align 4
; CHECK-NEXT:    [[CMP1_NOT_PEEL_I_I_I_I_I_I:%.*]] = icmp eq i32 [[TMP0]], 1
; CHECK-NEXT:    br i1 [[CMP1_NOT_PEEL_I_I_I_I_I_I]], label [[_ZNK6OPENMC6FILTER12GET_ALL_BINSERKNS_8PARTICLEENS_14TALLYESTIMATORERNS_11FILTERMATCHE_INTERNALIZED_EXIT_I:%.*]], label [[WHILE_COND_PEEL_NEXT_I_I_I_I_I_I:%.*]]
; CHECK:       while.cond.peel.next.i.i.i.i.i.i:
; CHECK-NEXT:    br label [[_ZNK6OPENMC6FILTER12GET_ALL_BINSERKNS_8PARTICLEENS_14TALLYESTIMATORERNS_11FILTERMATCHE_INTERNALIZED_EXIT_I]]
; CHECK:       _ZNK6openmc6Filter12get_all_binsERKNS_8ParticleENS_14TallyEstimatorERNS_11FilterMatchE.internalized.exit.i:
; CHECK-NEXT:    [[DOTLCSSA_I_I_I_I_I_I:%.*]] = phi i64 [ 0, [[FOR_BODY_I]] ], [ [[PHI_CAST_I_I_I_I]], [[WHILE_COND_PEEL_NEXT_I_I_I_I_I_I]] ]
; CHECK-NEXT:    store ptr null, ptr [[D_I_I_I_I]], align 8
; CHECK-NEXT:    [[ARRAYIDX92_I_I_I_I:%.*]] = getelementptr inbounds [3 x double], ptr [[D_I_I_I_I]], i64 0, i64 [[DOTLCSSA_I_I_I_I_I_I]]
; CHECK-NEXT:    [[TMP1:%.*]] = load double, ptr [[ARRAYIDX92_I_I_I_I]], align 8
; CHECK-NEXT:    store double [[TMP1]], ptr inttoptr (i64 16 to ptr), align 16
; CHECK-NEXT:    br i1 [[C2]], label [[FOR_BODY_I]], label [[_ZN6OPENMC13FILTERBINITERC2ERKNS_5TALLYERNS_8PARTICLEE_INTERNALIZED_EXIT]]
; CHECK:       _ZN6openmc13FilterBinIterC2ERKNS_5TallyERNS_8ParticleE.internalized.exit:
; CHECK-NEXT:    ret void
;
entry:
  %d.i.i.i.i = alloca [3 x double], align 8
  br i1 %c1, label %for.body.lr.ph.i, label %_ZN6openmc13FilterBinIterC2ERKNS_5TallyERNS_8ParticleE.internalized.exit

for.body.lr.ph.i:                                 ; preds = %entry
  %phi.cast.i.i.i.i = ptrtoint ptr %d.i.i.i.i to i64
  br label %for.body.i

for.body.i:
  %0 = load i32, ptr inttoptr (i64 4 to ptr), align 4
  %idx.ext87.i.i.i.i = sext i32 %0 to i64
  %add.ptr88.i.i.i.i = getelementptr inbounds double, ptr %d.i.i.i.i, i64 %idx.ext87.i.i.i.i
  %cmp1.not.peel.i.i.i.i.i.i = icmp eq i32 %0, 1
  br i1 %cmp1.not.peel.i.i.i.i.i.i, label %_ZNK6openmc6Filter12get_all_binsERKNS_8ParticleENS_14TallyEstimatorERNS_11FilterMatchE.internalized.exit.i, label %while.cond.peel.next.i.i.i.i.i.i

while.cond.peel.next.i.i.i.i.i.i:                 ; preds = %for.body.i
  br label %_ZNK6openmc6Filter12get_all_binsERKNS_8ParticleENS_14TallyEstimatorERNS_11FilterMatchE.internalized.exit.i

_ZNK6openmc6Filter12get_all_binsERKNS_8ParticleENS_14TallyEstimatorERNS_11FilterMatchE.internalized.exit.i: ; preds = %while.cond.peel.next.i.i.i.i.i.i, %for.body.i
  %.lcssa.i.i.i.i.i.i = phi i64 [ 0, %for.body.i ], [ %phi.cast.i.i.i.i, %while.cond.peel.next.i.i.i.i.i.i ]
  store ptr null, ptr %d.i.i.i.i, align 8
  %arrayidx92.i.i.i.i = getelementptr inbounds [3 x double], ptr %d.i.i.i.i, i64 0, i64 %.lcssa.i.i.i.i.i.i
  %1 = load double, ptr %arrayidx92.i.i.i.i, align 8
  store double %1, ptr inttoptr (i64 16 to ptr), align 16
  br i1 %c2, label %for.body.i, label %_ZN6openmc13FilterBinIterC2ERKNS_5TallyERNS_8ParticleE.internalized.exit

_ZN6openmc13FilterBinIterC2ERKNS_5TallyERNS_8ParticleE.internalized.exit:
  ret void
}
;.
; CHECK: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind }
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CGSCC: {{.*}}
; TUNIT: {{.*}}
